package com.itheima.iostream;

import java.io.FileInputStream;
import java.io.IOException;

public class ByteStreamDemo7 {
    public static void main(String[] args) throws IOException {
        //public int read(byte[] b)
        //一次读一个字节数组个数据

        byte[] bytes = new byte[2];
        FileInputStream fis = new FileInputStream("day28-code\\a.txt");
         //read方法会把读取到的数据放到bytes数组中，并返回读取的字节数
        int len1 = fis.read(bytes);

        String str1 = new String(bytes);
        System.out.println(str1);
        System.out.println(len1);

        int len2 = fis.read(bytes);
        String str2 = new String(bytes);
        System.out.println(str2);
        System.out.println(len2);

        int len3 = fis.read(bytes);
        String str3 = new String(bytes,0,len3);
        System.out.println(str3);
        System.out.println(len3);


    }
}
